import { PORT3 } from "@/api/config/servicePort";
import http from "@/api";
import { defaultParams } from "@/interface/public";
import { WorkerSo } from "../interface/workerSo";

const PORT = `${PORT3}/workerSo`;

interface ItemParamsProps {
  id: string | number;
  itemIds: string;
}

// 1-保存工单
export const workerSoSave = (params: WorkerSo.Save) => http.post(PORT + `/save`, params);

// 分拣工单查询
export const workerSoPage = (params: WorkerSo.ReqSearchParams) => http.post<WorkerSo.Search[]>(PORT + `/page`, params);

// 2-查询工单明细
export const workerSoItem = (params: defaultParams) => http.get<WorkerSo.SearchDetail[]>(PORT + `/item/${params.id}`);

// 3-为工单追加明细
export const workerSoAppendMaterial = (params: ItemParamsProps) => http.post(PORT + `/appendMaterial`, params);

// 4-查询待关联的清单
export const workerSoWaitAppendItem = (params: defaultParams) => http.get(PORT + `/waitAppendItem/${params.id}`);

// 5-为工单删除明细
export const workerSoRemoveMaterial = (params: ItemParamsProps) => http.post(PORT + `/removeMaterial`, params);

// 6-删除工单
export const workerSoRemove = (params: defaultParams) => http.post(PORT + `/remove/${params.id}`);

// 7-查询待开始工单
export const workerSoListByWaitStart = () => http.get<WorkerSo.Search[]>(PORT + `/listByWaitStart`);

// 7.1-开始工单
export const workerSoStart = (params: defaultParams) => http.post(PORT + `/start/${params.id}`);

// 8-查询待结束工单
export const workerSoListByWaitEnd = () => http.get(PORT + `/listByWaitEnd`);

// 8.1-结束工单
export const workerSoEnd = (params: defaultParams) => http.post(PORT + `/end/${params.id}`);

// 9-查询待发送物料的工单
export const workerSoListByWaitSend = () => http.get(PORT + `/listByWaitSend`);

// 9.1-查询工单下待发送物料明细
export const workerSoWaitSendByWorker = (params: defaultParams) => http.get(PORT + `/waitSendByWorker/${params.id}`);

// 9.2-工单发料
export const workerSoSendMaterial = (params: ItemParamsProps) => http.post(PORT + `/sendMaterial`, params);

// 10-查询待发送物料的工单
export const workerSoListByWaitAccept = () => http.get(PORT + `/listByWaitAccept`);

//10.1-查询工单下待接收物料明细
export const workerSoWaitAcceptByWorker = (params: defaultParams) => http.get(PORT + `/waitAcceptByWorker/${params.id}`);

// 10.2-工单收料
export const workerSoAcceptMaterial = (params: ItemParamsProps) => http.post(PORT + `/acceptMaterial`, params);

// 9.3-工单发料退回
export const workerSoBackSendMaterial = (params: ItemParamsProps) => http.post(PORT + `/backSendMaterial`, params);

// 11-变更明细的分拆标识
export const workerSoUpFlagSoSplit = (params: { itemId: number; flagSo: number; flagSplit: number }) =>
  http.post(PORT + `/upFlagSoSplit`, params);
